

// ReSharper disable RedundantExtendsListEntry

namespace AakStudio.Shell.UI.Showcase.ControlViews;

public partial class ReportDesigner : UserControl
{
    private readonly ReoGridControl reoGridControl;
    public ReportDesigner()
    {
        InitializeComponent();
        // 创建 ReoGrid 控件
        reoGridControl = new ReoGridControl();
        // 设置控件大小
        reoGridControl.Dock = DockStyle.Fill;
        
        // 将 ReoGrid 控件添加到 WindowsFormsHost 中
        Grid.Child = reoGridControl;
        reoGridControl.CurrentWorksheet.AutoSplitPage();
        reoGridControl.CurrentWorksheet.EnableSettings(WorksheetSettings.View_ShowPageBreaks);
        // 填充一些示例数据
    }
    
    private void Select_Color_Click(object sender, RoutedEventArgs e)
    {
        PopupElement.PlacementTarget = sender as UIElement;
        PopupElement.IsOpen = !PopupElement.IsOpen;
        if (sender is Button b)
        {
            SelectColor.Tag = b.Name;
        }
    }

    private void ColorPicker_OnCanceled(object? sender, EventArgs e)
    {
        PopupElement.IsOpen = false;
    }

    private void OnIncrementValue(object sender, RoutedEventArgs e)
    {
        reoGridControl.CurrentWorksheet.RowCount++;
    }

    private void OnDecrementValue(object sender, RoutedEventArgs e)
    {
        reoGridControl.CurrentWorksheet.RowCount--;
    }

    private void Columns_OnIncrementValue(object sender, RoutedEventArgs e)
    {
        reoGridControl.CurrentWorksheet.ColumnCount++;
    }

    private void Columns_OnDecrementValue(object sender, RoutedEventArgs e)
    {
        reoGridControl.CurrentWorksheet.ColumnCount--;
    }
}